#ifndef CORE_EXECUTOR_HPP
#define CORE_EXECUTOR_HPP

#include "Pose.hpp"
#include "../command/ICommand.hpp"
#include <vector>
#include <string>
#include <memory>

class Executor {
    // 关键：声明所有命令类为友元，授权访问 private 成员
    friend class MoveCommand;
    friend class TurnLeftCommand;
    friend class TurnRightCommand;
    friend class FastCommand;
    friend class ReverseCommand;
    friend class TurnRoundCommand;

private:
    Pose currentPose;
    bool isAccelerated;
    bool isReversed;

    // 内部辅助函数（现在命令类可以直接调用）
    void move(int steps);
    void turnLeft();
    void turnRight();

public:
    Executor();
    void init(int32_t x, int32_t y, char heading);
    Pose getCurrentState() const;
    bool IsAccelerated() const;
    bool IsReversed() const;

    void executeCommand(const std::unique_ptr<ICommand>& cmd);
    void executeCmd(char cmdChar);
    void executeBatchCmds(const std::vector<char>& cmds);
    void executeBatchCmds(const std::string& cmdStr);
};

#endif // CORE_EXECUTOR_HPP